package com.ybu.service.impl;

import com.ybu.common.ServiceCode;
import com.ybu.common.ServiceException;
import com.ybu.mapper.FavoriteListMapper;
import com.ybu.pojo.vo.FavoriteListVO;
import com.ybu.pojo.vo.ProductVO;
import com.ybu.pojo.vo.UserLoginVO;
import com.ybu.service.FavoriteListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class FavoriteListServiceImpl implements FavoriteListService {

    @Autowired
    private FavoriteListMapper favoriteListMapper;

    @Override
    public List<FavoriteListVO> getFavoriteList(UserLoginVO userLoginVO) {
        List<FavoriteListVO> favoriteList  = favoriteListMapper.getFavoriteList(userLoginVO.getId());
        if (favoriteList == null || favoriteList.isEmpty()){
            throw  new ServiceException(ServiceCode.ERR_FORBIDDEN,"查询失败");
        }

        return favoriteList;
    }
}
